package com.itheima.test;

import java.util.Random;

public class Test3 {
    public static void main(String[] args) {
        //需求：定义方法实现随机产生一个5位的验证码
        //验证码格式：
        //长度为5
        //前四位是大写字母或者小写字母
        //最后一位是数字
        char[] arr = new char[52];
        for (int i = 0; i < arr.length; i++) {
            if(i <= 25){
                arr[i] = (char) (97 + i);
            }else {
                arr[i] = (char) (65 + i - 26);
            }
        }
        String result = printnumber(arr);
        System.out.println(result);
    }
    public static String printnumber(char[] arr){
        Random r = new Random();
        String result = "";
        for (int i = 0; i < 4; i++) {
            int randomindex = r.nextInt(52);
            result += arr[randomindex];
        }
        result += r.nextInt(10);
        return result;
    }
}
